package Model;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Player class holds information about the player. 
 * File is able to be saved to a file and loaded later.
 * @author Tim
 * @version 1.0 11/16/2012
 */
@SuppressWarnings("serial")
public class Player implements Serializable{

	/** The player's name */
	private String name;
	/** the amount of money the player has to spend */
	private int money;
	/** the ship the player owns */
	private Ship ship;
	/** the player's statistics */
	private int[] skills = new int[4];
	/** how good/evil the player is in the eyes of the law */
	private int rep;
	/** describes the player's gender */
	private boolean female;
	/** determines how hard the game is intended to be */
	private final int difficulty;
	
	/**
	 * Player Constructor
	 * @param name Player name
	 * @param skills Array of player skills
	 * @param female player gender
	 * @param difficulty Player's current reputation in the game. 
	 * Used to calculate the likely hood of random search events.
	 */
	public Player(String name, int[] skills, boolean female, int difficulty){
		ship = new Ship(2);//default ship is gnat
		money = 100000;
		this.name = name;
		rep = 20;  
		this.female = female;
		this.difficulty = difficulty;
		this.skills = skills.clone();
	}
	
	/**
	 * Returns the player's name
	 * @return player name
	 */
	public String getName(){
		return name;
	}
	
	/**
	 * Sets the player's name
	 * @param name
	 */
	public void setName(String name){
		this.name = name;
	}
	
	/**
	 * Returns the player's money
	 * @return player money
	 */
	public int getMoney(){
		return money;
	}
	
	/**
	 * Sets the player's number
	 * @param m
	 */
	public void setMoney (int m){
		money = m;
	}
	
	/**
	 * Get's the player's current ship
	 * @return player ship
	 */
	public Ship getShip(){
		return ship;
	}
	
	/**
	 * Sets the player's current ship
	 * @param ship
	 */
	public void setShip(Ship ship){
		this.ship = ship;
	}
	
	/**
	 * Gets an int array of player skills
	 * @return int array of player skills
	 */
	public int[] getSkills(){
		return skills;
	}
	
	/**
	 * Sets int array of player skills
	 * @param skills
	 */
	public void setSkills(int[] skills){
		this.skills = skills.clone();
	}
	
	/**
	 * Gets the player's current reputation
	 * @return player's current reputation
	 */
	public int getRep(){
		return rep;
	}
	
	/**
	 * Sets the player's current reputation
	 * @param rep
	 */
	public void setRep(int rep){
		this.rep = rep;
	}
	
	/**
	 * Gets player's gender
	 * @return player gender
	 */
	public boolean getFemale(){
		return female;
	}
	
	/**
	 * Sets player's gender
	 * @param female
	 */
	public void setFemale(boolean female){
		this.female = female;
	}
	
	/**
	 * Returns the level of fuel for the ship
	 * @return integer fuel size
	 */
	public int getShipFuel(){
		return ship.getFuel();
	}//end method getFuel
	
	/**
	 * returns the trade goods which the ship already carries
	 * @return TradeGood[] shipsCargo
	 */
	public Map<String,TradeGood> getShipCargo(){
		return ship.getCargo();
	}//end method getShipCargo
	
	/**
	 * return the maximum amount of cargo the ship can carry
	 * @return integer maxCargo
	 */
	public int getShipMaxCargo(){
		return ship.getMaxCargo();
	}//end method getShipMaxCargo
	
	/**
	 * return the number of cargo spaces filled in the ship
	 * @return integer currCargo
	 */
	public int getCurrentCargo(){
		return ship.getCurrCargo();
	}//end method getCurrentCargo
	
	/**
	 * Set the current cargo amount
	 * @param currCargo
	 */
	public void setCurrCargo(int currCargo){
		ship.setCurrCargo(currCargo);
	}//end method setCurrCargo
	
	/**
	 * Set the cargo for player ship
	 * @param goods
	 */
	public void setCargo(Map<String,TradeGood> goods){
		ship.setCargo((HashMap<String, TradeGood>) goods);
	}//end method setCargo
	
	/**
	 * Returns the ship's fuel capacity
	 * @return integer of fuelCap
	 */
	public int getShipFuelCap(){
		return ship.getFuelCap();
	}
	
	/**
	 * Sets the amount of fuel the ship has
	 * @param newFuel
	 */
	public void setShipFuel(int newFuel){
		ship.setFuel(newFuel);
	}
	
	/**
	 * toString method
	 * @return String of object
	 */
	public String toString(){
		final String str = null;
		return str;
	}
}
